package com.sfjswl.fp.core.flow;

import com.sfjswl.fp.core.context.RuleRoam;
import com.sfjswl.fp.core.leaf.roam.BaseLeafRoamFlow;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true)
public class ScoreFlow extends BaseLeafRoamFlow {

  private double score;

  private String key;

  /*
   * 叶子节点流程处理
   *
   * @param roam 传递roam
   */
  @Override
  protected boolean doRoamFlow(RuleRoam roam) {
    Object value = roam.getValue(key);
    if (value == null) {
      return false;
    }
    double valueScore = Double.parseDouble(value.toString());
    return !(valueScore < score);
  }
}
